﻿<UserControl x:Class="PresentationProject.ClassControl1"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:PresentationProject"
             xmlns:tools="clr-namespace:_3DTools"
             mc:Ignorable="d" Background="Black"
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <local:SphereMeshGenerator x:Key="sphere" Center="0 0 0 " Radius="1.2" Stacks="32" Slices="64"/>
        <Storyboard x:Key="Storyboard1">
            <Point3DAnimationUsingKeyFrames Storyboard.TargetName="cam" Storyboard.TargetProperty="Position">
                <SplinePoint3DKeyFrame KeyTime="0:0:0" Value="0 -3 50" />
                <SplinePoint3DKeyFrame KeyTime="0:0:1.5" KeySpline="0.00,0.00 0.00,0.30" Value="0 -1 28" />
                <SplinePoint3DKeyFrame KeyTime="0:0:3" KeySpline="0.00,0.00 0.30,0.00" Value="0 0 6" />
            </Point3DAnimationUsingKeyFrames>
            <DoubleAnimationUsingKeyFrames Storyboard.TargetName="YRotate" Storyboard.TargetProperty="Angle">
                <SplineDoubleKeyFrame KeyTime="0:0:0" Value="600" />
                <SplineDoubleKeyFrame KeyTime="0:0:1.5" Value="300" />
                <SplineDoubleKeyFrame KeyTime="0:0:3" KeySpline="0.00,0.00 0.00,0.10" Value="20" />
            </DoubleAnimationUsingKeyFrames>
        </Storyboard>
    </UserControl.Resources>
    <Grid>
        <tools:TrackballDecorator x:Name="trackball">
            <tools:Interactive3DDecorator >
                <Viewport3D x:Name="viewport" >
                    <Viewport3D.Camera>
                        <PerspectiveCamera x:Name="cam" Position="0,0,50" LookDirection="0,0,-6" UpDirection="0,1,0">
                            <PerspectiveCamera.Transform>
                                <TranslateTransform3D x:Name="earthoffset" OffsetZ="0">
                                </TranslateTransform3D>
                            </PerspectiveCamera.Transform>
                        </PerspectiveCamera>

                    </Viewport3D.Camera>

                    <ModelUIElement3D x:Name="earthmodel" >
                        <ModelUIElement3D.Model>
                            <GeometryModel3D Geometry ="{Binding Source={StaticResource sphere},
                                               Path=Geometry}">
                                <GeometryModel3D.Material>
                                    <DiffuseMaterial>
                                        <DiffuseMaterial.Brush>
                                            <ImageBrush ImageSource="/Resources/Images/earthmap.jpg"/>
                                        </DiffuseMaterial.Brush>
                                    </DiffuseMaterial>
                                </GeometryModel3D.Material>
                                <GeometryModel3D.Transform>
                                    <RotateTransform3D >
                                        <RotateTransform3D.Rotation>
                                            <AxisAngleRotation3D x:Name="YRotate" Angle="0" Axis="-1,5,1" />
                                        </RotateTransform3D.Rotation>
                                    </RotateTransform3D>
                                </GeometryModel3D.Transform>
                            </GeometryModel3D>
                        </ModelUIElement3D.Model>

                    </ModelUIElement3D>
                    <ModelVisual3D>
                        <ModelVisual3D.Content>
                            <Model3DGroup>
                                <AmbientLight Color="#404040"/>
                                <DirectionalLight Color="#C0C0C0" Direction="0 0 -10" />
                                <DirectionalLight Color="#C0C0C0" Direction="-5 -10 10" />
                            </Model3DGroup>
                        </ModelVisual3D.Content>
                    </ModelVisual3D>
                </Viewport3D>
            </tools:Interactive3DDecorator>
        </tools:TrackballDecorator>
    </Grid>
</UserControl>
